home *** CD-ROM | disk | FTP | other *** search
/ PC World 2004 December / PCWorld_2004-12_cd.bin / software / temacd / tiny / tf6pro-6[1].0.140.exe / Tiny Firewall Pro 6.0.msi / conditions.js < prev    next >
Encoding:
JavaScript  |  2004-07-20  |  2.0 KB  |  71 lines

  1. /*//////////////////////////////////////////////////////////////////////
  2. filename:         conditions.js
  3. copyright(c):     Tiny Software cortp 2002, 2003 (http://www.tinysoftware.com)
  4. author:         Jozef Palocko (jpalocko@tinysoftware.com)
  5. product:         Tiny Personal Firewall 5.x                
  6. description:     implemetation of Global conditions HTML code
  7. ///////////////////////////////////////////////////////////////////////*/
  8.  
  9. //main function
  10.  
  11.  
  12. //return conditions string as HTMLcode
  13. function GetConditionsHtml(strFile)
  14. {
  15.     var strConditions = "";
  16.     var xmlDoc = LoadDOM (strFile); 
  17.     //get all checked conditions
  18.     var CheckedConditions =  window.external.GetConditions();
  19.      // Query a node-set.
  20.     var oNodes = xmlDoc.selectNodes('//Condition[@Type = "Global"]');
  21.     for (i=0; i<oNodes.length; i++)
  22.     {
  23.        oNode = oNodes.nextNode;
  24.        if (oNode != null) 
  25.        {
  26.            sIdValue = oNode.getAttribute("id");
  27.            cndName = Math.pow(2, parseInt( sIdValue));  
  28.            bChecked = cndName & CheckedConditions?1:0;
  29.            strConditions += GetCheckBoxHtml(cndName, oNode.text, bChecked) + "<br>";
  30.        }
  31.     }
  32.  
  33.     return strConditions;
  34. }
  35. //condition checkbox handler
  36. function OnClickedCheckbox(CheckBox)
  37. {
  38.     cndMask = parseInt(CheckBox.name);
  39.     bState = CheckBox.checked? 1:0;
  40.     //set state of checked condition
  41.     window.external.SetConditions(cndMask, bState);
  42. }
  43.  
  44. //return string with Checkbox tag HTML code
  45. function GetCheckBoxHtml(strName, strText, bSelected)
  46. {
  47.     Val ="";
  48.     if (bSelected)
  49.         Val = "CHECKED";
  50.     return '<input type="checkbox" '+ Val + ' name="' + strName + '" OnClick="OnClickedCheckbox(this)">' + strText ;
  51. }
  52.   
  53. //load XML document
  54. function LoadDOM(strFile)
  55. {
  56.     var dom;
  57.     try 
  58.     {
  59.         dom = new ActiveXObject("MSXML2.DOMDocument.4.0");
  60.         dom.async = false;
  61.         dom.validateOnParse = false;
  62.         dom.resolveExternals = false;
  63.         dom.load(strFile);
  64.     }
  65.     catch (e) 
  66.     {
  67.         alert(e.description);
  68.     }
  69.     return dom;
  70. }
  71.